<template>
  <div class="main">
    <el-dialog
      title="审核"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
    >
      <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
        <el-form-item label="审核状态" prop="status">
          <el-radio-group v-model="ruleForm.status">
            <el-radio :label="1">通过</el-radio>
            <el-radio :label="2">驳回</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
          <el-input v-model="ruleForm.remarks" type="textarea" />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="send">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { getUserAudit } from '@/api/userAttestation/index'
export default {
  data() {
    return {
      dialogVisible: false,
      ruleForm: {
        status: '',
        remarks: '',
        id: ''
      },
      rules: {
        status: [
          { required: true, message: '请选择状态', trigger: 'blur' }
        ],
        remarks: [
          { required: true, message: '请填写备注', trigger: 'blur' }
        ]
      }
    }
  },
  created() {
  },
  methods: {
    getRemove() {
      this.$refs.ruleForm && this.$refs.ruleForm.clearValidate()
    },
    open() {
      this.getRemove()
      this.dialogVisible = true
    },
    handleClose() {
      this.ruleForm = {}
      this.getRemove()
      this.dialogVisible = false
    },
    send() {
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          getUserAudit(this.ruleForm).then(res => {
            if (res.code == 200) {
              this.dialogVisible = false
              this.$emit('getQuery')
            } else {
              this.$message.error(res.msg)
            }
          })
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">

</style>
